<div ng-controller="tableCtrl">
	<!-- #fields -->
	<div class="panel panel-default">
		<div class="panel-heading">{{table.name}}结构</div>
		<table class="table table-striped table-hover">
			<colgroup>
				<col width="21%">
				<col width="21%">
				<col width="10%">
				<col width="15%">
				<col width="3%">
				<col width="5%">
				<col width="25%">
			</colgroup>
			<thead>
				<tr>
					<th>名称</th>
					<th>代码</th>
					<th>类型</th>
					<th class="text-right">长度</th>
					<th>&nbsp;</th>
					<th>空</th>
					<th>备注</th>
				</tr>
			</thead>
			<tbody>
				<tr ng-repeat="field in fields" ng-hide="empty(fields)">
					<td ng-bind="field.name"></td>
					<td ng-bind="field.code"></td>
					<td ng-bind="field.type"></td>
					<td ng-bind="field.length" class="text-right"></td>
					<td>&nbsp;</td>
					<td ng-bind="field.nullable"></td>
					<td ng-bind-html="field.remark"></td>
				</tr>
				<tr ng-show="empty(fields)">
					<td colspan="7" class="text-center">&{'common.empty'}</td>
				</tr>
			</tbody>
		</table>
	</div>
	<!-- #fields -->
</div>

<script type="text/javascript">
'use strict';
function tableCtrl($scope, $http) {
	angular.extend($scope, {
		// 初始化
		init: function() {
			$scope.loadFields($scope.table);
		},
		
		// 加载数据库表字段
		loadFields: function(table) {
			$http({
				method: 'get',
				url: '@{Databases.fields()}/' + table.id
			}).success(function(data) {
				$scope.fields = data;
			});
		},
		
		// 加载数据库表索引
		loadIndexs: function(table) {
			
		}
	}).init();
}
</script>
